<input type="color" id="bgcolor" onchange="changeBg()" />

<script>
  
  if(localStorage.getItem("bc")){
    document.body.style.background = localStorage.getItem("bc");
    bgcolor.value = localStorage.getItem("bc");
  }

  function changeBg(){
    document.body.style.background = bgcolor.value;
    localStorage.setItem("bc",bgcolor.value);
  }
</script>
